//
//  FileInterface.m
//  Contacts
//
//  Created by 李 雷川 on 14-8-9.
//  Copyright (c) 2014年 李 雷川. All rights reserved.
//

#import "FileInterface.h"
#import "DateMethod.h"

@implementation FileInterface
+(BOOL)saveLatestNoticesWithNotices:(NSArray *)notices{
    BOOL success = [notices writeToFile:LATEST_NOTICES_FILE atomically:YES];
    return success;
}

+(NSArray *)getLatestNotices{
    NSArray *notices = [NSArray arrayWithContentsOfFile:LATEST_NOTICES_FILE];
    return notices;
}

+(BOOL)saveInterfaceUpdateTime:(NSDictionary *)dic{
    BOOL success = [dic writeToFile:UPDATETIME_FILE atomically:YES];
    return success;
}

+(NSDictionary *)getLastUpdateTime{
    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:UPDATETIME_FILE];
    return dic;
}

+(NSArray *)getLastContacts{
    NSArray *arr = [NSArray arrayWithContentsOfFile:LASTCONTACT_FILE];
    return arr;
}

+(BOOL)saveContactInfo:(NSInteger)contactID{
    NSString *ID = [NSString stringWithFormat:@"%ld",contactID];
    NSArray *arr = [NSArray arrayWithContentsOfFile:LASTCONTACT_FILE];
    NSMutableArray *mArr = [NSMutableArray arrayWithArray:arr];
    [mArr removeObject:ID];
    [mArr addObject:ID];
    BOOL success = [mArr writeToFile:LASTCONTACT_FILE atomically:YES];
    return success;
}
@end
